package com.tanhua.server.controller;


import com.alibaba.fastjson.JSONObject;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
/**
 * @author 钱柏羽
 * 测灵魂控制器
 */
@RestController
@RequestMapping("/testSoul")
public class TestSoulController {
    @Autowired
    private TestSoulService testSoulService;
    @PostMapping(name="调查投送")
    public ResponseEntity surveyPost(@RequestBody Map map){
        String reportId = testSoulService.getSurveyScore(JSONObject.toJSONString(map.get("answers")));
        return ResponseEntity.ok(reportId);
    }
    @GetMapping(value = "/report/{id}",name="调查结果")
    public ResponseEntity reportView(@PathVariable("id") String reportId){
        return ResponseEntity.ok(testSoulService.reportView(reportId));
    }
    @GetMapping(name="题目展示")
    public ResponseEntity surveyView(){
        return testSoulService.surveyView();
    }

}
